<div class="form-group pull-right">
  <pfng-toast-notification-list [notifications]="notifications" 
      (onCloseSelect)="handleCloseNotification($event)" [showClose]="true">
  </pfng-toast-notification-list>
</div>

<div *ngIf="resolvedAPIVersion && resolvedPackageAPI">
  <div class="container-fluid breadcrumb-bar">
    <div class="row">
      <ol class="breadcrumb">
        <li><a [routerLink]="['/hub']">Microcks Hub</a></li>
        <li><a [routerLink]="['/hub/package', resolvedPackage!.name]">{{ resolvedPackage!.displayName }}</a></li>
        <li>{{ resolvedAPIVersion.id }} v. {{ resolvedAPIVersion.version }}</li>
      </ol>
    </div>
  </div>

  <div class="mh-page-header_inner container-sm">
    <div class="mh-api-header-content" *ngIf="resolvedAPIVersion">
      <div class="mh-api-header_image-container">
        <img class="mh-api-header_image" src="{{ resolvedAPIVersion.thumbUrl }}" alt>
      </div>
      <div class="mh-api-header_info">
        <h1 class="mh-api-header_title">{{ resolvedAPIVersion.displayName }}</h1>
        <div class="mh-api-header_version">version {{resolvedAPIVersion.version }}</div>
      </div>
    </div>
  </div>

  <div class="mh-page-contents">
    <div class="mh-page-contents_inner">
      <div class="mh-api-page row" *ngIf="resolvedAPIVersion && resolvedPackageAPI">
        <div class="col-md-3 col-md-push-9 col-sm-3 col-sm-push-9 col-xs-12">
          <div class="mh-api-page_side-panel">
            <button type="button" (click)="openModal(installModal)" class="mh-button mh-button-primary">Install</button>

            <div class="mh-api-page_side-panel_separator"></div>
            
            <div class="properties-side-panel-pf">
              <div class="properties-side-panel-pf-property">
                <h5 class="properties-side-panel-pf-property-label">Version</h5>
                <div class="properties-side-panel-pf-property-value">
                  <div class="dropdown btn-group" dropdown>
                    <button id="version-dropdown" type="button" dropdownToggle aria-controls="dropdown-actions" aria-haspopup="true" aria-expanded="false"
                        class="mh-api-page_side-panel_version-dropdown dropdown-toggle btn btn-default">
                      {{ resolvedAPIVersion.version }} <span *ngIf="resolvedAPIVersion.version === resolvedPackageAPI.currentVersion"> (Current)</span> <span class="caret"></span>
                    </button>
                    <ul id="dropdown-actions" role="menu" class="dropdown-menu" aria-labelledby="version-dropdown">
                      <li *ngFor="let apiVersion of resolvedPackageAPI.versions">
                        <a role="dropdown-item" [routerLink]="['..', apiVersion.name]">{{ apiVersion.version }} <span *ngIf="apiVersion.version === resolvedPackageAPI.currentVersion">(Current)</span></a>
                      </li>
                    </ul>
                  </div>
                </div>
              </div>
              <div class="properties-side-panel-pf-property">
                <h5 class="properties-side-panel-pf-property-label">
                  <span>
                    <span>Capability Level</span>
                    <span aria-hidden="true" class="fa fa-question-circle mh-capability-level-popover_icon"></span>
                    <a class="mh-external-link indicator mh-capability-level-popover_link" href="https://github.com/operator-framework/operator-sdk/blob/master/doc/images/operator-capability-level.png" target="_blank" rel="noopener noreferrer"></a>
                  </span>
                </h5>
                <div class="properties-side-panel-pf-property-value">
                  <span>
                    <span class="sr-only">{{ resolvedAPIVersion.capabilityLevel }}</span>
                    <img class="mh-api-page_side-panel_image" src="{{ renderCapabilityLevel() }}" alt="{{ resolvedAPIVersion.capabilityLevel }}">
                  </span>
                </div>
              </div>
              <div class="properties-side-panel-pf-property">
                <h5 class="properties-side-panel-pf-property-label">Provider</h5>
                <div class="properties-side-panel-pf-property-value">
                  <!-- {{ resolvedAPIVersion.provider }} --> &nbsp;
                  <span class="badge" [ngClass]="{'badge-light':resolvedPackage!.source=='Community', 'badge-success':resolvedPackage!.source=='Enterprise'}">{{ resolvedPackage!.source }}</span>
                </div>
              </div>
              <div class="properties-side-panel-pf-property">
                <h5 class="properties-side-panel-pf-property-label">Links</h5>
                <div *ngFor="let link of resolvedAPIVersion.links" class="properties-side-panel-pf-property-value">
                  <a class="mh-external-link block indicator" href="{{ link.url }}" target="_blank" rel="noopener noreferrer">{{ link.name }}</a>
                </div>
              </div>
              <div class="properties-side-panel-pf-property">
                <h5 class="properties-side-panel-pf-property-label">Contracts</h5>
                <div *ngFor="let contract of resolvedAPIVersion.contracts" class="properties-side-panel-pf-property-value">
                  <a class="mh-external-link indicator" href="{{ contract.url }}" target="_blank" rel="noopener noreferrer">{{ contract.type }}</a>
                </div>
              </div>
              <div class="properties-side-panel-pf-property">
                <h5 class="properties-side-panel-pf-property-label">Created At</h5>
                <div class="properties-side-panel-pf-property-value">{{ resolvedAPIVersion.createdAt | date:'EE MMM d, y'}}</div>
              </div>
              <div class="properties-side-panel-pf-property">
                <h5 class="properties-side-panel-pf-property-label">Maintainers</h5>
                <div *ngFor="let maintainer of resolvedAPIVersion.maintainers" class="properties-side-panel-pf-property-value">
                  <div>{{ maintainer.name }}</div>
                  <a href="mailto:{{ maintainer.email }}">{{ maintainer.email }}</a>
                </div>
              </div>
              <div class="properties-side-panel-pf-property">
                <h5 class="properties-side-panel-pf-property-label">Categories</h5>
                <div class="properties-side-panel-pf-property-value">
                  <div *ngFor="let category of resolvedPackage!.categories">{{ category }}</div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="col-md-9 col-md-pull-3 col-sm-9 col-sm-pull-3 col-xs-12">
          <h1>{{ resolvedAPIVersion.displayName }}</h1>
          <div class="mh-api-markdown-view" [innerHTML]="renderDescription()"></div>
        </div>
      </div>

      <!-- Modal -->
      <!--
      <div class="modal fade mh-api-install-modal" bsModal #installModal="bs-modal" *ngIf="resolvedAPIVersion && resolvedPackage" tabindex="-1" role="dialog" aria-labelledby="mh-api-install-modal-label" aria-hidden="true">
        <div class="modal-dialog modal-lg" role="document">
          <div class="modal-content">
      -->
            <ng-template #installModal>

            <div class="modal-header">
              <header class="catalog-item-header-pf pull-left">
                <img class="catalog-item-header-pf-icon" src="{{ resolvedAPIVersion.thumbUrl }}" alt="">
                <div class="catalog-item-header-pf-text">
                  <h1 class="catalog-item-header-pf-title" id="mh-api-install-modal-label">{{ resolvedAPIVersion.displayName }}</h1>
                  <h5 class="catalog-item-header-pf-subtitle">version {{ resolvedAPIVersion.version }} <!-- provided by {{ resolvedAPIVersion.provider }} --></h5>
                </div>
              </header>
              <button type="button" class="close pull-right" data-dismiss="modal" aria-label="Close" (click)="modalRef?.hide()">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
            <div class="modal-body">
              <h3>2 options for installing this API Mocks into your Microcks instance:</h3>
              
              <div class="row mh-api-install-modal_row">
                <div class="col-md-6">
                  <h4>1. Create new Import Jobs for API mocks</h4>
                </div>
                <div class="col-md-3">
                  <button class="mh-button mh-button-primary" (click)="installByImporterCreation()"><span class="fa fa-plus"></span> Add an Import Job</button>
                </div>
                <div class="col-md-2">
                  <button class="mh-button mh-button-navig" data-dismiss="modal" (click)="navigateToImporters()" *ngIf="importJobId"><span class="fa fa-check"></span> Go</button>
                </div>
              </div>
              <div class="row mh-api-install-modal_row">
                <div class="col-md-6">
                  <h4>2. Just import the API mocks once</h4>
                </div>
                <div class="col-md-3">
                  <button class="mh-button mh-button-primary" (click)="installByDirectUpload()"><span class="fa fa-plus"></span> Direct import </button>
                </div>
                <div class="col-md-2">
                  <button class="mh-button mh-button-navig" data-dismiss="modal" (click)="navigateToService()" *ngIf="discoveredService"><span class="fa fa-check"></span> Go</button>
                </div>
              </div>
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-default" data-dismiss="modal" (click)="modalRef?.hide()">Close</button>
            </div>

            </ng-template>
          <!--
          </div>
        </div>
      </div>
      -->  
      
      <!--
      <div id="capability-level-help" role="tooltip" class="fade in mh-capability-level-popover popover left"
        style="display: block; top: 400px; left: 449.922px;">
        <div class="arrow" style="top: 50%;"></div>
        <div class="popover-content">
          <img class="mh-capability-level-popover_img" src="/assets/images/capability-level-diagram.svg" alt="">
        </div>
      </div>
      -->
    </div>
  </div>
</div>